package com.xsdl.state.branch;

import com.xsdl.state.State;

public class MarioStateMachine {
    private int score;
    private State currentState;

    public MarioStateMachine() {
        this.score = 0;
        this.currentState = State.SMALL;
    }

    public void obtainMushRoom() {
        if (State.SMALL.getValue() == currentState.getValue()) {
            score += 100;
            currentState = State.SUPER;
        }
    }

    public void obtainCape() {
        if (State.SMALL.getValue() == currentState.getValue()) {
            score += 200;
            currentState = State.CAPE;
            return;
        }
        if (State.SUPER.getValue() == currentState.getValue()) {
            score += 200;
            currentState = State.CAPE;
        }
    }

    public void obtainFireFlower() {
        if (State.SMALL.getValue() == currentState.getValue()) {
            score += 300;
            currentState = State.FIRE;
            return;
        }
        if (State.SUPER.getValue() == currentState.getValue()) {
            score += 300;
            currentState = State.FIRE;
        }
    }

    public void meetMonster() {
        if (State.SUPER.getValue() == currentState.getValue()) {
            score -= 100;
            currentState = State.SMALL;
            return;
        }
        if (State.CAPE.getValue() == currentState.getValue()) {
            score -= 200;
            currentState = State.SMALL;
            return;
        }
        if (State.FIRE.getValue() == currentState.getValue()) {
            score -= 300;
            currentState = State.SMALL;
        }
    }

    public int getScore() {
        return this.score;
    }

    public State getCurrentState() {
        return this.currentState;
    }

}
